﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TMS_BackEnd.Models.He;

namespace TMS_BackEnd.Configers
{
    public class Sys_userConfiger : IEntityTypeConfiguration<Sys_user>
    {
        //        `user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
        //`dept_id` bigint(20) DEFAULT NULL COMMENT '部门ID',
        //`user_name` varchar(30) NOT NULL COMMENT '用户账号',
        //`nick_name` varchar(30) NOT NULL COMMENT '用户昵称',
        //`user_type` varchar(2) DEFAULT '00' COMMENT '用户类型（00系统用户）',
        //`email` varchar(50) DEFAULT '' COMMENT '用户邮箱',
        //`phonenumber` varchar(11) DEFAULT '' COMMENT '手机号码',
        //`sex` char (1) DEFAULT '0' COMMENT '用户性别（0男 1女 2未知）',
        //`avatar` varchar(100) DEFAULT '' COMMENT '头像地址',
        //`password` varchar(100) DEFAULT '' COMMENT '密码',
        //`status` char (1) DEFAULT '0' COMMENT '帐号状态（0正常 1停用）',
        //`del_flag` char (1) DEFAULT '0' COMMENT '删除标志（0代表存在 2代表删除）',
        //`login_ip` varchar(128) DEFAULT '' COMMENT '最后登录IP',
        //`login_date` datetime DEFAULT NULL COMMENT '最后登录时间',
        //`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
        //`create_time` datetime DEFAULT NULL COMMENT '创建时间',
        //`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
        //`update_time` datetime DEFAULT NULL COMMENT '更新时间',
        //`remark` varchar(500) DEFAULT NULL COMMENT '备注',
        public void Configure(EntityTypeBuilder<Sys_user> builder)
        {
            builder.ToTable(nameof(Sys_user));
            builder.HasKey(e => e.User_id);
            builder.Property(e => e.Dept_id).HasColumnType("bigint");
            builder.Property(e => e.User_name).HasMaxLength(30).IsRequired();
            builder.Property(e => e.Nick_name).HasMaxLength(30).IsRequired();
            builder.Property(e => e.User_type).HasMaxLength(2).HasDefaultValue("00");
            builder.Property(e => e.Email).HasMaxLength(50);
            builder.Property(e => e.Phonenumber).HasMaxLength(11);
            builder.Property(e => e.Sex).HasColumnType("char").HasMaxLength(1).HasDefaultValue("0");
            builder.Property(e => e.Avatar).HasMaxLength(100);
            builder.Property(e => e.Password).HasMaxLength(11);
            builder.Property(e => e.Status).HasColumnType("char").HasMaxLength(1).HasDefaultValue('0');
            builder.Property(e => e.Del_flag).HasMaxLength(1).HasDefaultValue('0').HasColumnType("char");
            builder.Property(e => e.Login_ip).HasMaxLength(128);
            builder.Property(e => e.Login_date).HasColumnType("datetime");
            builder.Property(e => e.Create_by).HasMaxLength(64);
            builder.Property(e => e.Create_time).HasColumnType("datetime");
            builder.Property(e => e.Update_by).HasMaxLength(64);
            builder.Property(e => e.Update_time).HasColumnType("datetime");
            builder.Property(e => e.Remark).HasMaxLength(500);
        }
    }
}
